package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;
import java.util.Map;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(47)
public class MoyuGameStrategy extends BaseGameStrategy {

    public static final String URL = "http://42.194.243.85:5000/api/send_mail";

    /**
     * {"name": "风云", "money": 55, "emoney": 55, "emoney2": 55, "moonvalue": 55}
     * @param item
     * @return
     */
    @GongnengMethod(4701)
    public String pay(SendItem item) {
        Map<String,String> params = new HashMap<>();
        params.put("name", item.uid);
        params.put(item.itemId, item.number);
        String s = RestTemplateUtil.sendPostJsonAndGetJsonKey(URL, params, "message");
        return s + "，重启到账邮件";
    }
    @GongnengMethod(4702)
    public String mail(SendItem item) {
        Map<String,String> params = new HashMap<>();
        params.put("name", item.uid);
        params.put("item", item.itemId);
        params.put("itemCount", item.number);
        String s = RestTemplateUtil.sendPostJsonAndGetJsonKey(URL, params, "message");
        return s + "，重启到账邮件";
    }



    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.uid = "是啊";
        item.number = "121";
        item.itemId = "1046422";
        System.out.println(new MoyuGameStrategy().mail(item));
    }
}

